﻿namespace ExamV5.ManagSys
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.IO;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using Wuqi.Webdiyer;

    public class ManagUserList : Page
    {
        protected Button butAdd;
        protected Button butAddMore;
        protected Button butExp;
        protected Button butQuery;
        protected GridView DataGridInfo;
        protected DropDownList DDLDept;
        protected DropDownList DDLQuery;
        protected DropDownList DDLUPDept;
        protected HtmlForm form1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        protected Label labRescordCount;
        protected Label labTip;
        protected LinkButton LBDel;
        protected LinkButton LBDelAll;
        protected LinkButton LBFirstPage;
        protected LinkButton LBLastPage;
        protected LinkButton LBNextPage;
        protected LinkButton LBNotUse;
        protected LinkButton LBPrevPage;
        protected LinkButton LBSelect;
        protected Label LBSend;
        private PublicFun publicFun_0 = new PublicFun();
        protected ScriptManager SM;
        protected TextBox txtQuery;
        protected UpdatePanel UPPart;

        protected AspNetPager aspPager;
        protected void butExp_Click(object sender, EventArgs e)
        {
            if (this.ViewState["UserPower"].ToString() == "Y")
            {
                try
                {
                    string cmdText = "";
                    string key = Guid.NewGuid().ToString("N").ToUpper();
                    string path = base.Server.MapPath("../") + @"\PublicFile\ExpUserInfo" + key + ".csv";
                    string str3 = "";
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                    StreamWriter writer = new StreamWriter(path, true, Encoding.GetEncoding("GB2312"));
                    writer.WriteLine("准考证号,用户姓名,用户性别,所属部门,所属职务,所属学历,手机号码,身份证号,出生年月,参加工作,岗位名称,岗位级别,用户级别,指定登录IP");
                    if (!(this.ViewState["UserPower"].ToString() == "Y"))
                    {
                        cmdText = "select a.LoginIP,b.UPID,a.UserSex,a.JoinWorkDate,a.UserGWName,a.UserGWLevel,a.UserSFZH,a.UserEdu,a.UserAge,a.UserSFZH,a.HandCombNO,a.DeptID,a.ID,a.UserCode,a.UserName,b.DeptName,a.Worker,UserLevel=case a.UserLevel when 'A' then '考生' when 'B' then '分管员'  when 'C' then '管理员' end from UserInfo a,DeptInfo b where b.ID=0 and a.DeptID=b.ID ";
                        base.Response.Write("<script>alert('用户管理权限未开放！')</script>");
                    }
                    else
                    {
                        cmdText = "select a.LoginIP,b.UPID,a.UserSex,a.JoinWorkDate,a.UserGWName,a.UserGWLevel,a.UserSFZH,a.UserEdu,a.UserAge,a.UserSFZH,a.HandCombNO,a.DeptID,a.ID,a.UserCode,a.UserName,b.DeptName,a.Worker,UserLevel=case a.UserLevel when 'A' then '考生' when 'B' then '分管员'  when 'C' then '管理员' end from UserInfo a,DeptInfo b where a.DeptID=b.ID ";
                    }
                    if (this.DDLDept.SelectedItem.Value != "0")
                    {
                        cmdText = cmdText + " and a.DeptID in (select b.ID from DeptInfo b where " + this.publicFun_0.GetManagDeptID(this.publicFun_0.CheckString(this.DDLDept.SelectedItem.Value)) + ")";
                    }
                    if (this.txtQuery.Text.Trim() != "")
                    {
                        if (!(this.DDLQuery.SelectedItem.Value.Trim() == "UserLevel"))
                        {
                            cmdText = cmdText + " and " + this.publicFun_0.CheckString(this.DDLQuery.SelectedItem.Value) + " like '%" + this.publicFun_0.CheckString(this.txtQuery.Text) + "%'";
                        }
                        else
                        {
                            switch (this.txtQuery.Text.Trim())
                            {
                                case "考生":
                                    cmdText = cmdText + " and a.UserLevel='A'";
                                    break;

                                case "分管员":
                                    cmdText = cmdText + " and a.UserLevel='B'";
                                    break;

                                case "管理员":
                                    cmdText = cmdText + " and a.UserLevel='C'";
                                    break;
                            }
                        }
                    }
                    cmdText = cmdText + " and a.Flag='A' and UserCode is not null order by " + this.ViewState["SortFiled"].ToString() + this.ViewState["SortType"].ToString();
                    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                    connection.Open();
                    SqlCommand command = new SqlCommand(cmdText, connection);
                    SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                    while (reader.Read())
                    {
                        str3 = "";
                        str3 = ((str3 + reader["UserCode"].ToString().Trim() + "\x00b7,") + reader["UserName"].ToString().Trim() + ",") + reader["UserSex"].ToString().Trim() + ",";
                        if (!(reader["UPID"].ToString().Trim() != "0"))
                        {
                            str3 = str3 + reader["DeptName"].ToString().Trim() + ",";
                        }
                        else
                        {
                            str3 = str3 + this.publicFun_0.GetValues("select DeptName from DeptInfo where ID=" + reader["UPID"].ToString().Trim(), "DeptName") + "＼" + reader["DeptName"].ToString().Trim() + ",";
                        }
                        str3 = (((((((((str3 + reader["Worker"].ToString().Trim() + ",") + reader["UserEdu"].ToString().Trim() + ",") + reader["HandCombNO"].ToString().Trim() + "\x00b7,") + reader["UserSFZH"].ToString().Trim() + "\x00b7,") + reader["UserAge"].ToString().Trim() + ",") + reader["JoinWorkDate"].ToString().Trim() + ",") + reader["UserGWName"].ToString().Trim() + ",") + reader["UserGWLevel"].ToString().Trim() + ",") + reader["UserLevel"].ToString().Trim() + ",") + reader["LoginIP"].ToString().Trim() + ",";
                        writer.WriteLine(str3);
                    }
                    reader.Close();
                    command.Dispose();
                    connection.Close();
                    connection.Dispose();
                    writer.Flush();
                    writer.Close();
                    this.labTip.Text = " 导出成功！单击【<a href='../FrmDownLoad.aspx?FileName=ExpUserInfo" + key + ".csv' target=_blank><font color=red>下载</font></a>】进行保存";
                }
                catch
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BExpErrTip", @"alert('导出数据失败！\n\n请将PublicFile目录设置为Everyone用户可修改权限！')", true);
                }
                finally
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
                }
            }
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void butQuery_Click(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = 0;
            this.aspPager.CurrentPageIndex = 1;
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DataGridInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.DataGridInfo.PageIndex = e.NewPageIndex;
            this.method_0();
        }

        protected void DataGridInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //if (e.Row.DataItemIndex == -1)
            //{
            //    this.DataGridInfo.Attributes.Add("oldValue", "#FFFFFF");
            //    this.DataGridInfo.Attributes.Add("singleValue", "#FFFFFF");
            //}
            //else
            //{
            //    e.Row.Attributes.Add("onmouseover", "this.bgColor='#F6F5F5'");
            //    if ((e.Row.DataItemIndex % 2) != 0)
            //    {
            //        e.Row.Attributes.Add("bgcolor", "#FFFFFF");
            //        e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('oldValue')");
            //    }
            //    else
            //    {
            //        e.Row.Attributes.Add("bgcolor", "#FFFFFF");
            //        e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('singleValue')");
            //    }
            //}
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label label2 = (Label)e.Row.Cells[7].FindControl("labEdit");
                Label label = (Label)e.Row.Cells[7].FindControl("labPower");
                label2.Text = "<a href='#' onclick=javascript:EditUser('" + this.DataGridInfo.DataKeys[e.Row.RowIndex]["ID"].ToString() + "');>" + label2.Text + "</a>";
                if (!(this.ViewState["ManagPower"].ToString() == "Y"))
                {
                    label.Enabled = false;
                }
                else
                {
                    label.Text = "<a href='#' onclick=javascript:SetUserPower('" + this.DataGridInfo.DataKeys[e.Row.RowIndex]["ID"].ToString() + "');>" + label.Text + "</a>";
                }
                if (this.DataGridInfo.DataKeys[e.Row.RowIndex]["UPID"].ToString().Replace("&nbsp;", "") != "0")
                {
                    e.Row.Cells[3].Text = this.publicFun_0.GetValues("select DeptName from DeptInfo where ID=" + this.publicFun_0.CheckString(this.DataGridInfo.DataKeys[e.Row.RowIndex]["UPID"].ToString().Replace("&nbsp;", "")), "DeptName") + "＼" + e.Row.Cells[3].Text;
                }
                CheckBox box = (CheckBox)e.Row.Cells[0].FindControl("CheckBoxSelect");
                if (!(!(e.Row.Cells[1].Text.Trim() == "admin") ? !(e.Row.Cells[1].Text.Trim() == this.httpCookie_0.Value) : false))
                {
                    box.Enabled = false;
                }
            }
            if (e.Row.RowType == DataControlRowType.Header)
            {
                if (this.ViewState["SortType"].ToString() != " Desc")
                {
                    switch (this.ViewState["SortFiled"].ToString())
                    {
                        case "UserCode":
                            e.Row.Cells[1].Controls.Add(new LiteralControl("↓"));
                            return;

                        case "UserName":
                            e.Row.Cells[2].Controls.Add(new LiteralControl("↓"));
                            return;

                        case "Worker":
                            e.Row.Cells[4].Controls.Add(new LiteralControl("↓"));
                            return;
                    }
                    e.Row.Cells[1].Controls.Add(new LiteralControl("↓"));
                }
                else
                {
                    switch (this.ViewState["SortFiled"].ToString())
                    {
                        case "UserCode":
                            e.Row.Cells[1].Controls.Add(new LiteralControl("↑"));
                            return;

                        case "UserName":
                            e.Row.Cells[2].Controls.Add(new LiteralControl("↑"));
                            return;

                        case "Worker":
                            e.Row.Cells[4].Controls.Add(new LiteralControl("↑"));
                            return;
                    }
                    e.Row.Cells[1].Controls.Add(new LiteralControl("↑"));
                }
            }
        }

        protected void DataGridInfo_Sorting(object sender, GridViewSortEventArgs e)
        {
            string sortExpression = e.SortExpression;
            if (!(this.ViewState["SortFiled"].ToString() == sortExpression))
            {
                this.ViewState["SortFiled"] = e.SortExpression;
            }
            else if (!(this.ViewState["SortType"].ToString() == " Desc"))
            {
                this.ViewState["SortType"] = " Desc";
            }
            else
            {
                this.ViewState["SortType"] = " ASC";
            }
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DataGridInfo_PreRender(object sender, EventArgs e)
        {
            // 使用<TH>替换<TD> 
            this.DataGridInfo.UseAccessibleHeader = true;
            //HeaderRow将被<thead>包裹，数据行将被<tbody>包裹
            this.DataGridInfo.HeaderRow.TableSection = TableRowSection.TableHeader;
        }

        protected void aspPager_PageChanged(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = this.aspPager.CurrentPageIndex - 1;
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DDLDept_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = 0;
            this.method_0();
        }

        protected void DDLUPDept_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DDLDept.Items.Clear();
            this.publicFun_0.LoadDeptInfo(this.DDLDept, this.DDLUPDept.SelectedItem.Value, this.httpCookie_0.Value, "B");
            if (this.DDLDept.Items.Count == 0)
            {
                if (!(this.DDLUPDept.SelectedItem.Value == "0"))
                {
                    ListItem item = new ListItem(this.DDLUPDept.SelectedItem.Text, this.DDLUPDept.SelectedItem.Value);
                    this.DDLDept.Items.Add(item);
                }
                else
                {
                    ListItem item2 = new ListItem("--所有部门--", "0");
                    this.DDLDept.Items.Insert(0, item2);
                }
            }
        }

        protected void LBDel_Click(object sender, EventArgs e)
        {
            bool flag = false;
            int num = 0;
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = null;
            for (int i = 0; i < this.DataGridInfo.Rows.Count; i++)
            {
                CheckBox box = (CheckBox)this.DataGridInfo.Rows[i].FindControl("CheckBoxSelect");
                if (box.Checked)
                {
                    num++;
                    if (!(this.publicFun_0.GetValues("select UserCode from ExamUser where UserCode='" + this.DataGridInfo.Rows[i].Cells[1].Text.Trim().Replace("&#183;", "\x00b7") + "'", "UserCode") == ""))
                    {
                        flag = true;
                    }
                    else
                    {
                        command = new SqlCommand("delete  from UserInfo where UserCode='" + this.DataGridInfo.Rows[i].Cells[1].Text.Trim().Replace("&#183;", "\x00b7") + "';Delete from UserPower where UserCode='" + this.DataGridInfo.Rows[i].Cells[1].Text.Trim().Replace("&#183;", "\x00b7") + "'", connection);
                        command.ExecuteNonQuery();
                        command.Dispose();
                        this.publicFun_0.ExecuteSql("insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('删除[" + this.DataGridInfo.Rows[i].Cells[1].Text.Trim().Replace("&#183;", "\x00b7") + "]用户信息！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
                    }
                }
            }
            connection.Close();
            connection.Dispose();
            if (this.DataGridInfo.Rows.Count == num)
            {
                this.DataGridInfo.PageIndex = 0;
            }
            this.method_0();
            this.LBSelect.Text = "选中当页";
            if (flag)
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('删除的部分人员中有考试记录暂无法删除！')", true);
            }
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void LBDelAll_Click(object sender, EventArgs e)
        {
            string strSql = "delete UserInfo where UserCode<>'admin';";
            strSql = ((((strSql + "delete UserPower where UserCode<>'admin';" + "truncate table DeptInfo;") + "delete SysParmInfo where ParmMemo='Worker';" + "delete SysParmInfo where ParmMemo='GWName';") + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考生','考生','Worker');" + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('管理员','管理员','Worker');") + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('技术岗','技术岗','GWName');" + "Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('业务岗','业务岗','GWName');") + "insert into DeptInfo(DeptName,UPID,SortInfo,DeptLevel) values('XXX局','0','1','0');" + "update UserInfo set DeptID=1 where UserCode='admin'";
            strSql = strSql + ";insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('清除所有人员只保留admin用户！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')";
            this.publicFun_0.ExecuteSql(strSql);
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BChCecAk", "alert('清除所有人员操作成功！')", true);
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void LBFirstPage_Click(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = 0;
            this.method_0();
        }

        protected void LBLastPage_Click(object sender, EventArgs e)
        {
            if (this.DataGridInfo.PageCount > 0)
            {
                this.DataGridInfo.PageIndex = this.DataGridInfo.PageCount - 1;
                this.method_0();
            }
        }

        protected void LBNextPage_Click(object sender, EventArgs e)
        {
            if (this.DataGridInfo.PageIndex < (this.DataGridInfo.PageCount - 1))
            {
                this.DataGridInfo.PageIndex++;
                this.method_0();
            }
        }

        protected void LBNotUse_Click(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = null;
            for (int i = 0; i < this.DataGridInfo.Rows.Count; i++)
            {
                CheckBox box = (CheckBox)this.DataGridInfo.Rows[i].FindControl("CheckBoxSelect");
                if (box.Checked)
                {
                    command = new SqlCommand("Update UserInfo set Flag='B' where UserCode='" + this.DataGridInfo.Rows[i].Cells[1].Text.Trim().Replace("&#183;", "\x00b7") + "'", connection);
                    command.ExecuteNonQuery();
                    this.publicFun_0.ExecuteSql("insert into SysLogInfo(LogDisp,EditUserCode,EditUser) values('禁用[" + this.DataGridInfo.Rows[i].Cells[1].Text.Trim().Replace("&#183;", "\x00b7") + "]用户信息！','" + this.httpCookie_0.Value + "','" + this.httpCookie_1.Value + "')");
                    command.Dispose();
                }
            }
            connection.Close();
            this.method_0();
            this.LBSelect.Text = "选中当页";
        }

        protected void LBPrevPage_Click(object sender, EventArgs e)
        {
            if (this.DataGridInfo.PageIndex > 0)
            {
                this.DataGridInfo.PageIndex--;
                this.method_0();
            }
        }

        protected void LBSelect_Click(object sender, EventArgs e)
        {
            int num;
            CheckBox box;
            if (this.LBSelect.Text != "选中当页")
            {
                for (num = 0; num < this.DataGridInfo.Rows.Count; num++)
                {
                    box = (CheckBox)this.DataGridInfo.Rows[num].FindControl("CheckBoxSelect");
                    box.Checked = false;
                }
                this.LBSelect.Text = "选中当页";
            }
            else
            {
                for (num = 0; num < this.DataGridInfo.Rows.Count; num++)
                {
                    box = (CheckBox)this.DataGridInfo.Rows[num].FindControl("CheckBoxSelect");
                    if (box.Enabled)
                    {
                        box.Checked = true;
                    }
                }
                this.LBSelect.Text = "取消所选";
            }
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        private void method_0()
        {
            string selectCommandText = "";
            if (this.ViewState["UserPower"].ToString() == "Y")
            {
                selectCommandText = "select a.HandCombNO,b.UPID,a.ID,a.UserCode,a.UserName,b.DeptName,a.Worker,UserLevel=case a.UserLevel when 'A' then '考生' when 'B' then '分管员'  when 'C' then '管理员' end from UserInfo a,DeptInfo b where a.DeptID=b.ID ";
            }
            else
            {
                selectCommandText = "select a.HandCombNO,b.UPID,a.ID,a.UserCode,a.UserName,b.DeptName,a.Worker,UserLevel=case a.UserLevel when 'A' then '考生' when 'B' then '分管员'  when 'C' then '管理员' end from UserInfo a,DeptInfo b where b.ID=0 and a.DeptID=b.ID ";
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BPower", "alert('用户管理权限未开放！')", true);
            }
            if (this.DDLDept.SelectedItem.Value != "0")
            {
                selectCommandText = selectCommandText + " and a.DeptID in (select b.ID from DeptInfo b where " + this.publicFun_0.GetManagDeptID(this.publicFun_0.CheckString(this.DDLDept.SelectedItem.Value)) + ")";
            }
            if (this.txtQuery.Text.Trim() != "")
            {
                if (!(this.DDLQuery.SelectedItem.Value.Trim() == "UserLevel"))
                {
                    selectCommandText = selectCommandText + " and " + this.publicFun_0.CheckString(this.DDLQuery.SelectedItem.Value) + " like '%" + this.publicFun_0.CheckString(this.txtQuery.Text) + "%'";
                }
                else
                {
                    string str3 = this.txtQuery.Text.Trim();
                    if (str3 != null)
                    {
                        if (str3 != "考生")
                        {
                            if (!(str3 == "分管员"))
                            {
                                if (str3 == "管理员")
                                {
                                    selectCommandText = selectCommandText + " and a.UserLevel='C'";
                                }
                            }
                            else
                            {
                                selectCommandText = selectCommandText + " and a.UserLevel='B'";
                            }
                        }
                        else
                        {
                            selectCommandText = selectCommandText + " and a.UserLevel='A'";
                        }
                    }
                }
            }
            selectCommandText = selectCommandText + " and a.Flag='A' and UserCode is not null order by " + this.ViewState["SortFiled"].ToString() + this.ViewState["SortType"].ToString();
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "DataInfo");
            this.DataGridInfo.DataSource = dataSet.Tables["DataInfo"].DefaultView;
            this.DataGridInfo.DataBind();
            //this.labRescordCount.Text = "总共&nbsp;<font color='#0000C0'><b>" + dataSet.Tables["DataInfo"].Rows.Count.ToString() + "</b></font>&nbsp;条记录&nbsp;<font color='#0000C0'><b>" + Convert.ToString((int) (this.DataGridInfo.PageIndex + 1)) + "/" + this.DataGridInfo.PageCount.ToString() + "</b></font>&nbsp;页&nbsp;";
            this.labRescordCount.Text = "总共&nbsp;<i>" + dataSet.Tables["DataInfo"].Rows.Count.ToString() + "</i>&nbsp;条记录&nbsp;<b>" + Convert.ToString((int)(this.DataGridInfo.PageIndex + 1)) + "/" + this.DataGridInfo.PageCount.ToString() + "</b>&nbsp;页&nbsp;";
            this.aspPager.RecordCount = dataSet.Tables["DataInfo"].Rows.Count;
            adapter.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if (!((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    if (this.publicFun_0.ReturnPaperData() != "Yes")
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                    }
                    else
                    {
                        this.txtQuery.Attributes.Add("onkeydown", "SubmitKeyClick('butQuery');");
                        if (!(this.httpCookie_0.Value == "admin"))
                        {
                            this.LBDelAll.Visible = false;
                        }
                        else
                        {
                            this.LBDelAll.Visible = true;
                            this.LBDelAll.Attributes.Add("onclick", @"javascript:{if(confirm('您当前删除是清除所有考生\n\n系统将清除所有考生、单位结构、职务、岗位等相关信息？\n\n系统只保留admin用户信息,您确定吗？')==false) return false;}");
                        }
                        this.ViewState["UserPower"] = this.publicFun_0.GetValues("select ManagUser from UserPower where UserCode='" + this.httpCookie_0.Value + "'", "ManagUser");
                        this.ViewState["ManagPower"] = this.publicFun_0.GetValues("select ManagPower from UserPower where UserCode='" + this.httpCookie_0.Value + "'", "ManagPower");
                        this.DDLUPDept.DataTextField = "DeptName";
                        this.DDLUPDept.DataValueField = "ID";
                        if (!(this.httpCookie_2.Value == "C"))
                        {
                            this.DDLUPDept.DataSource = this.publicFun_0.RetrunDataView("select ID,DeptName from DeptInfo where ID=" + this.httpCookie_3.Value + " order by SortInfo,ID");
                        }
                        else
                        {
                            this.DDLUPDept.DataSource = this.publicFun_0.RetrunDataView("select ID,DeptName from DeptInfo where UPID=0  order by SortInfo,ID");
                        }
                        this.DDLUPDept.DataBind();
                        if (!(this.httpCookie_2.Value == "C"))
                        {
                            this.DDLDept.Items.Clear();
                            this.publicFun_0.LoadDeptInfo(this.DDLDept, this.DDLUPDept.SelectedItem.Value, this.httpCookie_0.Value, "B");
                            if (this.DDLDept.Items.Count == 0)
                            {
                                ListItem item = new ListItem(this.DDLUPDept.SelectedItem.Text, this.DDLUPDept.SelectedItem.Value);
                                this.DDLDept.Items.Add(item);
                            }
                        }
                        else
                        {
                            this.DDLUPDept.SelectedIndex = -1;
                            this.DDLDept.SelectedIndex = -1;
                            ListItem item2 = new ListItem("--所有单位--", "0");
                            ListItem item3 = new ListItem("--所有部门--", "0");
                            this.DDLDept.Items.Insert(0, item3);
                            this.DDLUPDept.Items.Insert(0, item2);
                        }
                        if (this.ViewState["UserPower"].ToString() == "Y")
                        {
                            if (!(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='HandComb'", "ParmValue") == "1"))
                            {
                                this.LBSend.Enabled = false;
                            }
                            else
                            {
                                this.LBSend.Enabled = true;
                                this.LBSend.Text = "<a href='#' onclick=javascript:ShowSendUser();>发送手机短信</a>";
                            }
                        }
                        this.ViewState["SortFiled"] = " updateTime";
                        this.ViewState["SortType"] = " Desc";
                        this.LBNotUse.Attributes.Add("onclick", "javascript:{if(confirm('确定禁用所有选中人员吗？')==false) return false;}");
                        this.LBDel.Attributes.Add("onclick", "javascript:{if(confirm('确定删除所有选中人员吗？')==false) return false;}");
                        this.method_0();
                    }
                }
            }
        }
    }
}

